#ifndef STATEWIDGET_H
#define STATEWIDGET_H

#include "global.h"

#include <QWidget>
#include <QLabel>

class StateWidget : public QWidget
{
    Q_OBJECT
public:
    explicit StateWidget(QWidget *parent = nullptr);

    void setState(QString normal="", QString hover="", QString press="",
                  QString select="", QString select_hover="", QString select_press="");

    ClickLbState getCurState() const;
    void clearState();

    void setSelected(bool b_selected);

    // 添加红点
    void addRedPoint();
    void showRedPoint(bool show = true);

protected:
    void paintEvent(QPaintEvent* event);

    virtual void mousePressEvent(QMouseEvent *event) override;
    virtual void mouseReleaseEvent(QMouseEvent *event) override;
    virtual void enterEvent(QEvent* event) override;
    virtual void leaveEvent(QEvent* event) override;

signals:
    void clicked();

private:
    QString m_normal;
    QString m_normal_hover;
    QString m_normal_press;

    QString m_selected;
    QString m_selected_hover;
    QString m_selected_press;

    ClickLbState m_curstate;
    QLabel* m_red_point;
};

#endif // STATEWIDGET_H
